Hệ thống xếp lịch học tín chỉ cho sinh viên CNTT trên PHP & MySQL
112.151 lượt xem;
1 <?php
2 $currDir = dirname(__FILE__);
3 require("{$currDir}/incCommon.php");
4 $GLOBALS['page_title'] = $Translation['groups'];
5 include("{$currDir}/incHeader.php");
6
7 if($_GET['searchGroups'] != ""){
8 $searchSQL = makeSafe($_GET['searchGroups']);
9 $searchHTML = html_attr($_GET['searchGroups']);
10 $where = "where name like '%{$searchSQL}%' or description like '%{$searchSQL}%'";
11 }else{
12 $searchSQL = '';
13 $searchHTML = '';
14 $where = "";
15 }
16
17 $numGroups = sqlValue("select count(1) from membership_groups $where");
18 if(!$numGroups && $searchSQL != ''){
19 echo "<div class=\"alert alert-danger\">{$Translation['no matching results found']}</div>";
20 $noResults = true;
21 $page = 1;
22 }else{
23 $noResults = false;
24 }
25
26 $page = intval($_GET['page']);
27 if($page < 1){
28 $page = 1;
29 }elseif($page > ceil($numGroups / $adminConfig['groupsPerPage']) && !$noResults){
30 redirect("admin/pageViewGroups.php?page=" . ceil($numGroups / $adminConfig['groupsPerPage']));
31 }
32
33 $start = ($page - 1) * $adminConfig['groupsPerPage'];
34
35 ?>
36 <div class="page-header">
37 <h1>
38 <?php echo $Translation['groups']; ?>
39 <span class="pull-right"><a href="pageEditGroup.php" class="btn btn-success btn-lg"><i class="glyphicon glyphicon-plus"></i> <?php echo $Translation['add group']; ?></a></span>
40 <div class="clearfix"></div>
41 </h1>
42 </div>
43
44 <table class="table table-striped table-bordered table-hover">
45 <thead>
46 <tr>
47 <th colspan="4" class="text-center">
48 <form class="form-inline" method="get" action="pageViewGroups.php">
49 <input type="hidden" name="page" value="1">
50
51 <div class="form-group">
52 <label for="searchGroups"><?php echo $Translation['search groups'] ; ?></label>
53 <input class="form-control" type="text" id="searchGroups" name="searchGroups" value="<?php echo $searchHTML; ?>" size="20">
54 </div>
55 <div class="form-group">
56 <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> <?php echo $Translation['find']; ?></button>
57 <button type="button" class="btn btn-warning" onClick="window.location='pageViewGroups.php';"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['reset']; ?></button>
58 </div>
59 </form>
60 </th>
61 </tr>
62 <tr>
63 <th><?php echo $Translation["group"] ; ?></th>
64 <th><?php echo $Translation["description"] ; ?></th>
65 <th><?php echo $Translation['members count'] ; ?></th>
66 <th> </th>
67 </tr>
68 </thead>
69 <tbody>
70 <?php
71
72 $res = sql("select groupID, name, description from membership_groups $where limit $start, ".$adminConfig['groupsPerPage'], $eo);
73 while( $row = db_fetch_row($res)){
74 $groupMembersCount = sqlValue("select count(1) from membership_users where groupID='$row[0]'");
75 ?>
76 <tr>
77 <td><a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>"><?php echo $row[1]; ?></a></td>
78 <td><?php echo thisOr($row[2]); ?></td>
79 <td class="text-right"><?php echo $groupMembersCount; ?></td>
80 <td class="text-center">
81 <a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['Edit group']; ?>"><i class="glyphicon glyphicon-pencil"></i></a>
82 <?php if(!$groupMembersCount){ ?>
83 <a href="pageDeleteGroup.php?groupID=<?php echo $row[0]; ?>"
84 title="<?php echo $Translation['delete group'] ; ?>"
85 onClick="return confirm('<?php echo $Translation['confirm delete group'] ; ?>');">
86 <i class="glyphicon glyphicon-trash text-danger"></i>
87 </a>
88 <?php }else{ ?>
89 <i class="glyphicon glyphicon-trash text-muted"></i>
90 <?php } ?>
91 <a href="pageEditMember.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation["add new member"]; ?>"><i class="glyphicon glyphicon-plus text-success"></i></a>
92 <a href="pageViewRecords.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['view group records'] ; ?>"><i class="glyphicon glyphicon-th"></i></a>
93 <?php if($groupMembersCount){ ?>
94 <a href="pageViewMembers.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['view group members'] ; ?>"><i class="glyphicon glyphicon-user"></i></a>
95 <a href="pageMail.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['send message to group']; ?>"><i class="glyphicon glyphicon-envelope"></i></a>
96 <?php }else{ ?>
97 <i class="glyphicon glyphicon-user text-muted"></i>
98 <i class="glyphicon glyphicon-envelope text-muted"></i>
99 <?php } ?>
100 </td>
101 </tr>
102 <?php
103 }
104 ?>
105 </tbody>
106 <tfoot>
107 <tr>
108 <td colspan="4">
109 <table width="100%" cellspacing="0">
110 <tr>
111 <th class="text-left" width="33%">
112 <a class="btn btn-default" href="pageViewGroups.php?searchGroups=<?php echo $searchHTML; ?>&page=<?php echo ($page > 1 ? $page - 1 : 1); ?>"><?php echo $Translation['previous']; ?></a>
113 </th>
114 <th class="text-center" width="33%">
115 <?php
116 $originalValues = array ('<GROUPNUM1>','<GROUPNUM2>','<GROUPS>' );
117 $replaceValues = array ( $start+1 , $start+db_num_rows($res) , $numGroups );
118 echo str_replace ( $originalValues , $replaceValues , $Translation['displaying groups'] );
119 ?>
120 </th>
121 <th class="text-right">
122 <a class="btn btn-default" href="pageViewGroups.php?searchGroups=<?php echo $searchHTML; ?>&page=<?php echo ($page < ceil($numGroups / $adminConfig['groupsPerPage']) ? $page + 1 : ceil($numGroups / $adminConfig['groupsPerPage'])); ?>"><?php echo $Translation['next'] ; ?></a>
123 </th>
124 </tr>
125 </table>
126 </td>
127 </tr>
128 <tr>
129 <th colspan="4">
130 <b><?php echo $Translation['key'] ; ?></b>
131 <div class="row">
132 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-pencil text-info"></i> <?php echo $Translation['edit group details'] ; ?></div>
133 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-trash text-danger"></i> <?php echo $Translation['delete group'] ; ?></div>
134 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-plus text-success"></i> <?php echo $Translation['add member to group'] ; ?></div>
135 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-th text-info"></i> <?php echo $Translation['view data records'] ; ?></div>
136 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-user text-info"></i> <?php echo $Translation['list group members'] ; ?></div>
137 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-envelope text-info"></i> <?php echo $Translation['send email to all members'] ; ?></div>
138 </div>
139 </th>
140 </tr>
141 </tfoot>
142 </table>
143
144 <style>
145 .form-inline .form-group{ margin: 0.5em 1em; }
146 </style>
147
148 <?php
149 include("{$currDir}/incFooter.php");
150 ?>
2 $currDir = dirname(__FILE__);
3 require("{$currDir}/incCommon.php");
4 $GLOBALS['page_title'] = $Translation['groups'];
5 include("{$currDir}/incHeader.php");
6
7 if($_GET['searchGroups'] != ""){
8 $searchSQL = makeSafe($_GET['searchGroups']);
9 $searchHTML = html_attr($_GET['searchGroups']);
10 $where = "where name like '%{$searchSQL}%' or description like '%{$searchSQL}%'";
11 }else{
12 $searchSQL = '';
13 $searchHTML = '';
14 $where = "";
15 }
16
17 $numGroups = sqlValue("select count(1) from membership_groups $where");
18 if(!$numGroups && $searchSQL != ''){
19 echo "<div class=\"alert alert-danger\">{$Translation['no matching results found']}</div>";
20 $noResults = true;
21 $page = 1;
22 }else{
23 $noResults = false;
24 }
25
26 $page = intval($_GET['page']);
27 if($page < 1){
28 $page = 1;
29 }elseif($page > ceil($numGroups / $adminConfig['groupsPerPage']) && !$noResults){
30 redirect("admin/pageViewGroups.php?page=" . ceil($numGroups / $adminConfig['groupsPerPage']));
31 }
32
33 $start = ($page - 1) * $adminConfig['groupsPerPage'];
34
35 ?>
36 <div class="page-header">
37 <h1>
38 <?php echo $Translation['groups']; ?>
39 <span class="pull-right"><a href="pageEditGroup.php" class="btn btn-success btn-lg"><i class="glyphicon glyphicon-plus"></i> <?php echo $Translation['add group']; ?></a></span>
40 <div class="clearfix"></div>
41 </h1>
42 </div>
43
44 <table class="table table-striped table-bordered table-hover">
45 <thead>
46 <tr>
47 <th colspan="4" class="text-center">
48 <form class="form-inline" method="get" action="pageViewGroups.php">
49 <input type="hidden" name="page" value="1">
50
51 <div class="form-group">
52 <label for="searchGroups"><?php echo $Translation['search groups'] ; ?></label>
53 <input class="form-control" type="text" id="searchGroups" name="searchGroups" value="<?php echo $searchHTML; ?>" size="20">
54 </div>
55 <div class="form-group">
56 <button type="submit" class="btn btn-primary"><i class="glyphicon glyphicon-search"></i> <?php echo $Translation['find']; ?></button>
57 <button type="button" class="btn btn-warning" onClick="window.location='pageViewGroups.php';"><i class="glyphicon glyphicon-remove"></i> <?php echo $Translation['reset']; ?></button>
58 </div>
59 </form>
60 </th>
61 </tr>
62 <tr>
63 <th><?php echo $Translation["group"] ; ?></th>
64 <th><?php echo $Translation["description"] ; ?></th>
65 <th><?php echo $Translation['members count'] ; ?></th>
66 <th> </th>
67 </tr>
68 </thead>
69 <tbody>
70 <?php
71
72 $res = sql("select groupID, name, description from membership_groups $where limit $start, ".$adminConfig['groupsPerPage'], $eo);
73 while( $row = db_fetch_row($res)){
74 $groupMembersCount = sqlValue("select count(1) from membership_users where groupID='$row[0]'");
75 ?>
76 <tr>
77 <td><a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>"><?php echo $row[1]; ?></a></td>
78 <td><?php echo thisOr($row[2]); ?></td>
79 <td class="text-right"><?php echo $groupMembersCount; ?></td>
80 <td class="text-center">
81 <a href="pageEditGroup.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['Edit group']; ?>"><i class="glyphicon glyphicon-pencil"></i></a>
82 <?php if(!$groupMembersCount){ ?>
83 <a href="pageDeleteGroup.php?groupID=<?php echo $row[0]; ?>"
84 title="<?php echo $Translation['delete group'] ; ?>"
85 onClick="return confirm('<?php echo $Translation['confirm delete group'] ; ?>');">
86 <i class="glyphicon glyphicon-trash text-danger"></i>
87 </a>
88 <?php }else{ ?>
89 <i class="glyphicon glyphicon-trash text-muted"></i>
90 <?php } ?>
91 <a href="pageEditMember.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation["add new member"]; ?>"><i class="glyphicon glyphicon-plus text-success"></i></a>
92 <a href="pageViewRecords.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['view group records'] ; ?>"><i class="glyphicon glyphicon-th"></i></a>
93 <?php if($groupMembersCount){ ?>
94 <a href="pageViewMembers.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['view group members'] ; ?>"><i class="glyphicon glyphicon-user"></i></a>
95 <a href="pageMail.php?groupID=<?php echo $row[0]; ?>" title="<?php echo $Translation['send message to group']; ?>"><i class="glyphicon glyphicon-envelope"></i></a>
96 <?php }else{ ?>
97 <i class="glyphicon glyphicon-user text-muted"></i>
98 <i class="glyphicon glyphicon-envelope text-muted"></i>
99 <?php } ?>
100 </td>
101 </tr>
102 <?php
103 }
104 ?>
105 </tbody>
106 <tfoot>
107 <tr>
108 <td colspan="4">
109 <table width="100%" cellspacing="0">
110 <tr>
111 <th class="text-left" width="33%">
112 <a class="btn btn-default" href="pageViewGroups.php?searchGroups=<?php echo $searchHTML; ?>&page=<?php echo ($page > 1 ? $page - 1 : 1); ?>"><?php echo $Translation['previous']; ?></a>
113 </th>
114 <th class="text-center" width="33%">
115 <?php
116 $originalValues = array ('<GROUPNUM1>','<GROUPNUM2>','<GROUPS>' );
117 $replaceValues = array ( $start+1 , $start+db_num_rows($res) , $numGroups );
118 echo str_replace ( $originalValues , $replaceValues , $Translation['displaying groups'] );
119 ?>
120 </th>
121 <th class="text-right">
122 <a class="btn btn-default" href="pageViewGroups.php?searchGroups=<?php echo $searchHTML; ?>&page=<?php echo ($page < ceil($numGroups / $adminConfig['groupsPerPage']) ? $page + 1 : ceil($numGroups / $adminConfig['groupsPerPage'])); ?>"><?php echo $Translation['next'] ; ?></a>
123 </th>
124 </tr>
125 </table>
126 </td>
127 </tr>
128 <tr>
129 <th colspan="4">
130 <b><?php echo $Translation['key'] ; ?></b>
131 <div class="row">
132 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-pencil text-info"></i> <?php echo $Translation['edit group details'] ; ?></div>
133 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-trash text-danger"></i> <?php echo $Translation['delete group'] ; ?></div>
134 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-plus text-success"></i> <?php echo $Translation['add member to group'] ; ?></div>
135 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-th text-info"></i> <?php echo $Translation['view data records'] ; ?></div>
136 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-user text-info"></i> <?php echo $Translation['list group members'] ; ?></div>
137 <div class="col-sm-6 col-md-4 col-lg-3"><i class="glyphicon glyphicon-envelope text-info"></i> <?php echo $Translation['send email to all members'] ; ?></div>
138 </div>
139 </th>
140 </tr>
141 </tfoot>
142 </table>
143
144 <style>
145 .form-inline .form-group{ margin: 0.5em 1em; }
146 </style>
147
148 <?php
149 include("{$currDir}/incFooter.php");
150 ?>